<!DOCTYPE html>
<html lang="zh" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('叶子叶子单元列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.addFull()" shiro:hasPermission="workbench:leaf_unit_city:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()"
               shiro:hasPermission="workbench:leaf_unit_city:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    let editFlag = [[${@permission.hasPermi('workbench:leaf_unit_city:edit')}]]
    let removeFlag = [[${@permission.hasPermi('workbench:leaf_unit_city:remove')}]]
    let prefix = ctx + "workbench/leaf_unit_city_9"

    $(function () {
        let search = window.location.search
        let id = search.substr(4);
        loadTable(id)
    })

    /**
     * 加载表格
     */
    function loadTable(id) {
        let options = {
            url: prefix + "/list?id=" + id,
            createUrl: prefix + "/add?id=" + id,
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "所辖村庄",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: 'id',
                    visible: false
                },
                {
                    field: 'name',
                    title: '单元名称'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        let actions = []
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editFull(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ')
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>')
                        return actions.join('')
                    }
                }]
        }
        $.table.init(options)
    }
</script>
</body>
</html>
